package lq1457;

import java.util.Scanner;
/*
lq1457
逐级递推，通过40% 
也可以DP循环数组递推
AC需要找杨辉三角的规律
 * */
class Node{
	public long num;
	public Node next;
	public Node(long num, Node next) {
		this.num = num;
		this.next = next;
	}
}
public class Main {

	static Node yhHead;
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		
		//输入1直接返回结果
		if(n==1) {
			System.out.println(1);
			return;
		}
		
			
		//初始化第一行
		Node f = new Node(1,null);
		//初始化头节点
		yhHead = new Node(0,f);
		
		//当前行
		int l=1;
		//当前行第几个
		int m=1;
		//是否找到
		boolean isFind = false;
		
		//逐行查询n
		while(!isFind) {
			l++;
			//获取下一行
			yhNextLine();
			Node cur = yhHead.next;
			m = 1;
			while(cur!=null) {
				if(cur.num == n) {
					isFind = true;
					break;
				}
				cur = cur.next;
				m++;
			}
		}
	
		l--;
		int ans = (l*(l+1))/2 + m;
		System.out.println(ans);
	}

	static void yhNextLine() {
		//滑动窗口扩展链表到下一行
		Node left = yhHead;
		Node right = yhHead.next;
		
		//新一行的头节点
		Node newYh = new Node(0,null);
		//当前节点指针
		Node cur = newYh;
		while(left!=null) {
			Node n;
			//左加右构建节点
			if(right!=null)
				n = new Node(left.num+right.num,null);
			else
				n = new Node(left.num,null);
			
			//节点加入到cur的下一个
			cur.next = n;
			cur = n;
			
			//左和右同时后移
			left = left.next;
			if(right!=null)
				right = right.next;
		}
		
		//头节点指向下一行
		yhHead = newYh;
	}
}
